//
// Created by ct on 2021/2/2.
//

#ifndef SMCRYPTO_SM4_H
#define SMCRYPTO_SM4_H

//#include <openssl/opensslconf.h>
//#include <openssl/e_os2.h>



#include <cstdint>

// ECB
namespace sm4 {

    static const uint8_t SM4_ENCRYPT = 1;
    static const uint8_t SM4_DECRYPT = 0;
    static const uint8_t SM4_BLOCK_SIZE = 16;
    // SM4密钥表
    static const uint8_t SM4_KEY_SCHEDULE = 32;

    // round key
    typedef struct SM4_KEY_st {
        uint32_t rk[SM4_KEY_SCHEDULE];
    } SM4_KEY;

    int SM4_set_key(const uint8_t *key, SM4_KEY *ks);

    void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);

    void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);


}

#endif //SMCRYPTO_SM4_H
